import java.util.Scanner;

public class Demo {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int t = scan.nextInt();


        for(int i = 0; i < t; i++) {
            int n = scan.nextInt();
            int k = scan.nextInt();
            int[] arr1 = new int[n];
            int[] arr2 = new int[n];
            for(int j = 0; j < n; j++) {
                arr1[j] = scan.nextInt();
            }

            for(int y = 0; y < n; y++) {
                arr2[y] = scan.nextInt();
            }


            int[] array = new int[2*n];
            while(k > 0) {

                int count = 0;
                int g = 0;

                while(count < 2 * n) {
                    array[count++] = arr1[g];
                    array[count++] = arr2[g];
                    g++;
                }

                count = 0;

                    for(int l = 0; l < n; l++) {
                        arr1[l] = array[count++];
                    }

                    for(int l = 0; l < n; l++) {
                        arr2[l] = array[count++];
                    }



                k--;
            }
            for(int f = 0; f < 2*n; f++) {
                System.out.printf("%d ", array[f]);
            }
            System.out.println();
        }


    }
}
